Null module do loop perameter

What does the following error mean?

"null Module do loop parameter was passed"

I get this error every once and a while running scripts, and am actually having an issue with it.

A previous admin created a script that used "Link by Attribute..." but lets the user choose a baseline to link to. We are now getting the above error when linking to certain modules/baselines. I can sometimes get around this by creating a new baseline, but that isn't always the case...and I can't always create a new baseline. Any ideas where to start?

Thanks,
Corey
the@dmin - Thu Mar 26 13:24:48 EDT 2009

Re: Null module do loop perameter
dpechacek - Thu Mar 26 16:13:09 EDT 2009

It means that the Module handle that the script was trying to use for a do loop was null.

Check your code to make sure it is getting the Module/Baseline handles properly.

AAI Services, Textron
dpechacek@sc-aaicorp.com
David.Pechacek@gmail.com

Re: Null module do loop perameter
llandale - Fri Mar 27 10:38:38 EDT 2009

You might want to post the code, at least the part associated with the error. I think its likely your code does something strange, like closing a 'Module' and then using the 'Module' handle afterwards. Just guessing, but in this case I suspect you have some sort of 'for Module in Project' loop, and close the open module inside the loop.

>Louie

Re: Null module do loop perameter
the@dmin - Fri Mar 27 12:38:25 EDT 2009

llandale - Fri Mar 27 10:38:38 EDT 2009
You might want to post the code, at least the part associated with the error. I think its likely your code does something strange, like closing a 'Module' and then using the 'Module' handle afterwards. Just guessing, but in this case I suspect you have some sort of 'for Module in Project' loop, and close the open module inside the loop.

>Louie

Code is attached...USE AT YOUR OWN RISK!

The exact error I get is below. I still don't know what triggers the error, some baselines work fine, others don't.
-R-E- DXL: <Line:134> null Module do loop parameter was passed
Backtrace:
<Line:530>
<Line:572>
<Line:602>

Re: Null module do loop perameter
llandale - Mon Mar 30 13:31:32 EDT 2009

the@dmin - Fri Mar 27 12:38:25 EDT 2009
Code is attached...USE AT YOUR OWN RISK!

The exact error I get is below. I still don't know what triggers the error, some baselines work fine, others don't.
-R-E- DXL: <Line:134> null Module do loop parameter was passed
Backtrace:
<Line:530>
<Line:572>
<Line:602>

Posted the right code?? I see line 134 as (int old_pos = get linkAttributeList) inside function linkRefreshAttributeListCB(), and that function is not invoked anywhere near line 530. It appears your error code invokes something somewhere in the DXL library; I cannot figure out where.

At line 444 you use a 'suffix' variable, but that's a built in perm. I see it declared above and given value null, I wonder if that's really what you want. Don't you want to derive the ACTUAL baseline suffix from 'selectedBaseline'? Also at line 444 you get a 'baseline' handle, then check to see if it exists. This isn't going to work since the 'baseline' command always returns a handle based on the criteria, it has nothing to do with whether that baseline exists in the current module. Thus you never get the halt following it. I think you should move the halt code below the 'load' statement, halt if moduleToLinkTo is null. As it is, its possible that the moduleToLinkTo is in fact null which might trigger your problem.

When combined with my 'suffix' comment above, it appears you are failing to get a basline handle of the actual baseline, when that baseline has a suffix. This looks like your problem.

Your 'majorExp' regexp doesn't seem to care about the Suffix.

Also....

Golly, what lousy indendation. Very hard to read.

I wonder what will happen to your Regular expression 'modVer' at line 397 if the Suffix has a TAB in it...

It doesn't matter much, but your constant Regular Expressions should be defined globally even when only one function uses it, since the 'regexp' command takes an enourmous amount of time to execute; certainly much longer than it takes to use it.

I notice you define Skip variable moduleBaselines globally, and also define it local to function linkDoCreateLinks(). You do not delete this Skip list.

At line 198 you should not just check for null Module result, but if needed make sure its actually open for Edit; since the 'edit' command can indeed open the module for read (depending on a user response).

Is it possible that your 'trg_name' and 'src_Name' variables are read from your dialog box as unqualified names e.g. "MyModule", instead of full path names e.g. "/MyProject/MyFolder/MyModule"? If so, I suppose its possible the 'module' commands work based on the current folder, but subsequent 'read' or 'edit' commands don't work.

>Louie

Re: Null module do loop perameter
the@dmin - Mon Mar 30 15:36:11 EDT 2009

llandale - Mon Mar 30 13:31:32 EDT 2009
Posted the right code?? I see line 134 as (int old_pos = get linkAttributeList) inside function linkRefreshAttributeListCB(), and that function is not invoked anywhere near line 530. It appears your error code invokes something somewhere in the DXL library; I cannot figure out where.

At line 444 you use a 'suffix' variable, but that's a built in perm. I see it declared above and given value null, I wonder if that's really what you want. Don't you want to derive the ACTUAL baseline suffix from 'selectedBaseline'? Also at line 444 you get a 'baseline' handle, then check to see if it exists. This isn't going to work since the 'baseline' command always returns a handle based on the criteria, it has nothing to do with whether that baseline exists in the current module. Thus you never get the halt following it. I think you should move the halt code below the 'load' statement, halt if moduleToLinkTo is null. As it is, its possible that the moduleToLinkTo is in fact null which might trigger your problem.

When combined with my 'suffix' comment above, it appears you are failing to get a basline handle of the actual baseline, when that baseline has a suffix. This looks like your problem.

Your 'majorExp' regexp doesn't seem to care about the Suffix.

Also....

Golly, what lousy indendation. Very hard to read.

I wonder what will happen to your Regular expression 'modVer' at line 397 if the Suffix has a TAB in it...

It doesn't matter much, but your constant Regular Expressions should be defined globally even when only one function uses it, since the 'regexp' command takes an enourmous amount of time to execute; certainly much longer than it takes to use it.

I notice you define Skip variable moduleBaselines globally, and also define it local to function linkDoCreateLinks(). You do not delete this Skip list.

At line 198 you should not just check for null Module result, but if needed make sure its actually open for Edit; since the 'edit' command can indeed open the module for read (depending on a user response).

Is it possible that your 'trg_name' and 'src_Name' variables are read from your dialog box as unqualified names e.g. "MyModule", instead of full path names e.g. "/MyProject/MyFolder/MyModule"? If so, I suppose its possible the 'module' commands work based on the current folder, but subsequent 'read' or 'edit' commands don't work.

>Louie

Thanks Louie...as stated before, I did not write this code. I have had a difficult time trying to make sense of it. The person that wrote the code is not available to help correct it, and management is weaning me off of DOORS work. So, I will be looking at this as much as I can and sharing the information with new folks.

Thanks for the detailed analysis, it will help me get further that I would have on my own!

Corey

Re: Null module do loop perameter
llandale - Tue Mar 31 10:27:31 EDT 2009

the@dmin - Mon Mar 30 15:36:11 EDT 2009
Thanks Louie...as stated before, I did not write this code. I have had a difficult time trying to make sense of it. The person that wrote the code is not available to help correct it, and management is weaning me off of DOORS work. So, I will be looking at this as much as I can and sharing the information with new folks.

Thanks for the detailed analysis, it will help me get further that I would have on my own!

Corey

I didn't run the code. I don't know why you got the exact error that you got; but it feels like some sort of baseline call with a null module.

Not your fault, but this is one of worst pieces of code I've ever seen. Variables used for more than one purpose, multiple variables with the same purpose, global variables declared but not used, local variables with the same name as global variables, in one case defined within a function AFTER using the global variable with the same name, hokey variable names, embedded functions, return paramaters that are global variables, no comments of course, indentation out of whack and inconsistent, lots of code that contributes nothing, modifying modules with no 'save' command, opening modules with no 'close' commands, creating data structures with no 'delete' command, bla bla bla.

Understand that the "Baseline" variable stuff is confusing. If you use the "for bl in mod" loop you get an actual Baseline handle you can query, such as its date. Getting a Baseline handle in any other way, such as at line 444 "Baseline bl = baseline(maj, min, suffix)", returns a theoretical Baseline handle that may or may not exist, but that you cannot query even if it DOES exist. They should have used two data types for these two different notions, the second one perhaps "BaselineRef"; oh well.

Recent practicing with Regexp reveals that if the Regexp can match more than one sequence in the string, it will match the LAST one, not the FIRST one. In this case if the Annotation contains a TAB character, the "modver" regexp match at line 421 will match inside the Annotation; throwing the rest of that code into the Abyss.

Code below demonstrates the validity of two new regular expressions I wrote, versionWithSuffix and versionWithoutSuffix, based on well formed "moduleBaseline" string as created at line 364, adding tabs to the annotation. I note with curiosity the space before the second \t at line 364; that's in the regexp. Notice these two regular expressions start with "^", meaning "at the start of the string", just in case your Annotation contains something that looks like a baseline "3.2", followed by tabs. Notice they also look for "one or more digits" "+", rather than "zero or more characters", ".".

>>I think you can skip the two "modVer" checks at lines 413 and 421.
>>Use the two regular expressions below on the original string; there are oddly several variables with that value, "selectedBl" will do. If the with-suffix match works set the "maj", "min" and suffix, otherwise if the without-suffix match works set maj min and suffix="", otherwise you have an error.
>>Before (current) line 450, add a check for "baselineExists(trg_mod, bl)"
>>After (current) line 450, check for null "moduleToLinkTo".

Good luck.

Regexp versionWithSuffix = regexp "^([0-9]+)\\.([0-9]+)\\((.+)\\)(\t.+)( \t.+)"
Regexp versionWithoutSuffix = regexp "^([0-9]+)\\.([0-9]+)(\t.+)( \t.+)"

string moduleBaseline1 = "32.4(aa)\t2/4/2009 \tannotation\twith tab \t \t cc"
string moduleBaseline2 = "32.4\t2/4/2009 \tannotation\twith tab \t \t cc"

// print "Invalid [\n"

if (versionWithSuffix moduleBaseline1)
{ print "1 YES Suffix: ^" moduleBaseline1[match 1] "^\t*" moduleBaseline1[match 2] "*\t"
print "#" moduleBaseline1[match 3] "#\t^" moduleBaseline1[match 4] "^\n"
}
else print "1 No Yes suffix match\n"

if (versionWithoutSuffix moduleBaseline1)
{ print "1 NOT Suffix: ^" moduleBaseline1[match 1] "^\t*" moduleBaseline1[match 2] "*\t"
print "#" moduleBaseline1[match 3] "#\t^" moduleBaseline1[match 4] "^\n"
}
else print "1 No Not suffix match\n"
if (versionWithSuffix moduleBaseline2)
{ print "2 YES Suffix: ^" moduleBaseline2[match 1] "^\t*" moduleBaseline2[match 2] "*\t"
print "#" moduleBaseline2[match 3] "#\t^" moduleBaseline2[match 4] "^\n"
}
else print "2 No Yes suffix match\n"

if (versionWithoutSuffix moduleBaseline2)
{ print "2 NOT Suffix: ^" moduleBaseline2[match 1] "^\t*" moduleBaseline2[match 2] "*\t"
print "#" moduleBaseline2[match 3] "#\t^" moduleBaseline2[match 4] "^\n"
}
else print "2 No Not suffix match\n"